package database

import (
	"fmt"
	"github.com/astaxie/beego/orm"
	"github.com/larspensjo/config"
)

func InitDataBase(){
	error := orm.RegisterDriver("mysql", orm.DRMySQL)
	if error != nil{
		fmt.Println("register mysql fail")
	}
	c,_ := config.ReadDefault("./config/app.conf")
	database_uri,_ := c.String("database","database_uri")
	fmt.Println(database_uri)
	e := orm.RegisterDataBase("default","mysql",database_uri)
	if e != nil{
		fmt.Println("Register DataBase fail")
	}
	err := orm.RunSyncdb("default", false, false)
	fmt.Println(err)
}